package com.freesky.web.manager.controller.statistical;

import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.web.manager.remote.statistic.StatisticOrderRemote;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Freesky
 */
@Controller
@Api(description = "订单统计")
@RequestMapping("/statistic/order")
public class StatisticOrderController {

    @GetMapping("/page")
    public String page() {
        return "statistical/order";
    }

    @Autowired
    private StatisticOrderRemote orderRemote;

    @ResponseBody
    @GetMapping
    @ApiOperation(value = "订单统计")
    public JSONResponse countOrder(
            @RequestParam (value = "type")int type,
            @RequestParam(value = "startTime",required = false) String startTime,
            @RequestParam(value = "endTime",required = false) String endTime,
            @RequestParam(value = "year",required = false) int year) {
        return orderRemote.countOrder(type, startTime, endTime, year);

    }
}
